package org.puremvc.as3.demos.flex.cafetownsend.model.business
{
	import com.salesforce.AsyncResponder;
	import com.salesforce.Connection;
	import com.salesforce.objects.LoginRequest;
	import com.salesforce.results.LoginResult;
	import com.salesforce.results.QueryResult;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	
	import org.puremvc.as3.demos.flex.cafetownsend.ApplicationFacade;
	import org.puremvc.as3.demos.flex.cafetownsend.view.EmployeeLoginMediator;

	public class LoadContactsDelegate
	{
		private var force:Connection = new Connection();
		private var lr:LoginRequest = new LoginRequest();
		
		public var empLogMed:EmployeeLoginMediator;
		
		public var cList:ArrayCollection = new ArrayCollection();
		
		public function LoadContactsDelegate()
		{
		}
		
		public function getAllContacts(result:LoginResult):void {
			force.query("SELECT CreatedDate,Email,FirstName,LastName FROM Contact", new AsyncResponder(queryResult));
		}
		
		public function queryResult(result:QueryResult):void {
			cList = result.records;
			Alert.show("Contacts:"+cList.length);
		}
	}
}